﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using IterationLife.Datas;
using IterationLife.Domains.Sports.Services;
using IterationLife.Football.MTSports.Contracts.Sports;
using Util;
using Util.Datas;
using Util.Iocs;

namespace IterationLife.Football.MTSports.Impl.Sports
{
    public class DataImportService : IDataImportService, IDependency
    {
        /// <summary>
        /// 构造
        /// </summary>
        public DataImportService(IApplicationUnitOfWork unitOfWork, ISportUserService sportUserService, IDataImportManager dataImportManager)
        {
            DataImportManager = dataImportManager;
            SportUserService = sportUserService;
            UnitOfWork = unitOfWork;
        }

        /// <summary>
        /// 数据导入
        /// </summary>
        protected IDataImportManager DataImportManager { get; set; }

        /// <summary>
        /// 用户服务
        /// </summary>
        protected ISportUserService SportUserService { get; set; }

        /// <summary>工作单元</summary>
        protected IUnitOfWork UnitOfWork { get; private set; }

        /// <summary>
        /// 导入
        /// </summary>
        public void Import()
        {
            foreach (var sportUserDto in SportUserService.GetAll())
            {
                DataImportManager.Import(sportUserDto.Id.ToGuid());
            }
            UnitOfWork.Commit();
        }

    }
}